﻿using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Linq.Expressions;
using System.Reflection;
using vite_core.EF_Core.Model;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using vite_entity.Entities;

namespace vite_core.EF_Core.EFDbcontext
{
    /// <summary>
    /// DbContext上下文的实现 partial是需要的
    /// 一开始上手容易的到后面比较坑
    /// </summary>
    public partial class ViteNetDbContext : DbContext
    {
        public ViteNetDbContext()
        {
        }

        public ViteNetDbContext(DbContextOptions<ViteNetDbContext> options)
            : base(options)
        {
        }
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            //这里可以在program.cs中添加 optionsBuilder.UseMySql
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            // 需要安装包：Microsoft.EntityFrameworkCore.Relational
            modelBuilder.ApplyConfigurationsFromAssembly(typeof(SysMenu).Assembly);
        }

        public virtual DbSet<SysDept> SysDepts { get; set; }

        public virtual DbSet<SysDict> SysDicts { get; set; }

        public virtual DbSet<SysDictItem> SysDictItems { get; set; }

        public virtual DbSet<SysLog> SysLogs { get; set; }

        public virtual DbSet<SysMenu> SysMenus { get; set; }

        public virtual DbSet<SysMessage> SysMessages { get; set; }

        public virtual DbSet<SysRole> SysRoles { get; set; }

        public virtual DbSet<SysRoleMenu> SysRoleMenus { get; set; }

        public virtual DbSet<SysUser> SysUsers { get; set; }

        public virtual DbSet<SysUserRole> SysUserRoles { get; set; }

    }
}
